package org.nokatag.code;

import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.util.Iterator;

public abstract class AbstractFilterFactory
implements FilterFactory
{

public AbstractFilterFactory()
{
}

protected abstract java.util.List getFilters();

public BufferedImage applyFilters(BufferedImage source)
{
    BufferedImage dest = source;
    for(Iterator i$ = getFilters().iterator(); i$.hasNext();)
    {
        BufferedImageOp filter = (BufferedImageOp)i$.next();
        dest = filter.filter(dest, null);
    }

    int x = (source.getWidth() - dest.getWidth()) / 2;
    int y = (source.getHeight() - dest.getHeight()) / 2;
    source = new BufferedImage(source.getWidth(), source.getHeight(), source.getType());
    source.getGraphics().drawImage(dest, x, y, null);
    return source;
}
}
